// this is a special version of the Record class that always holds a 
// key, pointer pair; the first attribute is always a key, and the second
// attribute is always a pointer


#include <cstring>
#include "record.h"
#include "IndexRecord.h"
using namespace std;

//class IndexRecord : public Record {

//public:

	char* key;
	int keyLen;
	int pointer;

	// returns a -1, 0, or 1 depending upon whether the key value of the 
	// record falls below, in, or above the range that is given as a
	// parameter
	int IndexRecord :: Compare (Attribute &lowVal, Attribute &highVal, Type &myType)
	{
		switch(myType)
		{
			case Int:
			{
				if(key >= lowVal && key <= highVal)
					return 0;
				else if(key < lowVal)
					return -1;
				else if(key > highVal)
					return 1;
			}
			
			case Double:
			{
				if(key >= lowVal && key <= highVal)
					return 0;
				else if(key < lowVal)
					return -1;
				else if(key > highVal)
					return 1;
			}
			
			case String:
			{
				if (strcmp(key,lowVal) == 0 || strcmp(key,highVal) == 0)
					return 0;
				else if (strcmp(key,lowVal) < 0)
					return -1;
				else if (strcmp(key,highVal) > 0)
					return 1;
			}
			
			default:
				cout<<"Invalid Attribute Type";
		}
	}

	// this takes and copies the key, pointer pair into the record.  
	// keyLen is the number of bytes in the key.
	void IndexRecord :: Load (char *key, int keyLen, int pointer)
	{
	
	}

	// this gets the pointer value associated with the record
	int IndexRecord :: GetPointer ()
	{
		return 1;
	}
//}; 
